//
//  HXLSelectRateViewController.m
//  On The Load
//
//  Created by 晓琳 on 15/11/13.
//  Copyright © 2015年 @@叶一闽. All rights reserved.
//

#import "HXLSelectRateViewController.h"

@interface HXLSelectRateViewController () <UITableViewDataSource,UITableViewDelegate>

@end

@implementation HXLSelectRateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UITableView *rateTV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT- 64)];
    [self.view addSubview:rateTV];
    rateTV.delegate = self;
    rateTV.dataSource = self;
    
    
}

- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.allArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    NSString *cellIdentifer = @"rate";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (nil==cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifer];
    }
    cell.textLabel.text = [self.keyArray objectAtIndex:indexPath.row];
    
//    NSNumberFormatter *numFormatter = [[NSNumberFormatter alloc] init];
//    NSLog(@"%@", [self.allArray objectAtIndex:indexPath.row]);
    CGFloat f = [[self.allArray objectAtIndex:indexPath.row] floatValue];
    NSString *num = [NSString stringWithFormat:@"%f", f];
    
    cell.detailTextLabel.text = num;
    return cell;
}

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    NSNumber *rate = [self.allArray objectAtIndex:indexPath.row];
    [self.myDelegate getCurrentRate:rate];
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
